import Vue from 'vue'
import Vuex from 'vuex'
import label from './modules/label';
import Reply from './modules/Reply';
import CustomerTools from './modules/CustomerTools';
import serviceSetting from './modules/serviceSetting';
import CustomerContact from './modules/CustomerContact';
import material from './modules/material';
import dynamic from './modules/dynamic';
import Player from './modules/Player';
import sample from './modules/sample';
import appro from './modules/appro';
// Player
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token:localStorage.getItem("token"),
    user_id:localStorage.getItem("user_id"),
    root_router:localStorage.getItem("root_router"),
	custome:{
		show:false,
		msg:''
	},
	tim:{
		status:false,
		msg:null
	}
  },
  mutations: {
    SET_TOKEN:(state, token)=>{
      state.token = token;
      localStorage.setItem("token",token);
    },
    SET_USERID:(state, user_id)=>{
      state.user_id = user_id;
      localStorage.setItem("user_id",user_id);
    },
    SET_ROOT_ROUTER:(state,root_router)=>{
      state.root_router = root_router;
      localStorage.setItem('root_router',root_router)
    },
    // REMOVE_INFO:(state)=>{
    //   state.token = "";
    //   state.user_id = {};
    //   localStorage.setItem("token","");
    //   localStorage.setItem("user_id",JSON.stringify(""));
    // }
	
	SET_CUSTOME_SHOW(state,show){
		state.custome = {
			...state.custome,
			show:show
		}
	},
	SET_CUSTOME_MSG(state,msg){
		state.custome = {
			...state.custome,
			msg:msg
		}
	},
	SET_TIM_STATUS(state,msg){
		state.tim.status = msg
	},
	SET_TIM_MSG(state,msg){
		state.tim.msg = msg
	},
  },
  getters:{
    getUser_id: state =>{
      return state.user_id;
    },
    getToken:state =>{
      return state.token;
    },
  },
  actions: {

  },
  modules: {
    label,
    Reply,
    CustomerTools,
    serviceSetting,
    CustomerContact,
    material,
    dynamic,
    Player,
	sample,
	appro
  }
})